package concurrent.atomic;

import java.util.concurrent.atomic.AtomicBoolean;

public class AtomicBooleanTest {

	public static void main(String[] args) {
		
		AtomicBoolean atomicBoolean = new AtomicBoolean();
		atomicBoolean.set(true);
		System.out.println(atomicBoolean.get());

		//比较为真，才设置值
		atomicBoolean.compareAndSet(true, false);
		System.out.println(atomicBoolean.get());
		
		//设置为一个新值，并发旧值
		System.out.println(atomicBoolean.getAndSet(true));
		System.out.println(atomicBoolean.get());
	}
}
